package etnorservice.etnor_service.controller;

import etnorservice.etnor_service.result.Result;

import etnorservice.etnor_service.service.ApiServiceUrl;
import etnorservice.etnor_service.utils.JsonUtil;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: cc
 * @Date: 2024/06/30/15:24
 **/
@RestController
public class EnglishController {
    @Autowired
    ApiServiceUrl apiServiceUrl;
    @GetMapping("/english")
    public Object english(@RequestParam(value = "q", required = false) String query,
                          @RequestParam(value = "num", defaultValue = "1") int num,
                          @RequestParam(value = "doctype", defaultValue = "json") String doctype) throws IOException {
        String url="https://dict.youdao.com/suggest?q="+query+"&num=1&doctype=json";
        System.out.println(url);

        return JsonUtil.jsonStringToMap(apiServiceUrl.getWeatherInfo(url));
    }


       //https://dict.youdao.com/suggest?q=abandon&num=1&doctype=json



}
